$(document).ready(function() {
	getEmployee();
});


function getEmployee() {
	$.getJSON('CS56001Srvl', {
		process_type: "getEmployee",
	}, function(result) {
		var options = '';
		options += '<option value="">-- เลือกพนักงาน  --</option>';
		for (var i = 0; i < result.values.length; i++) {

			options += '<option value="' + result.values[i] + '">' + result.messages[i] +  '</option>';
		}
		$("#InputEmployee").html(options); 
	});
}

function printReport() {
	
	var vaDateStart = $("#datetimepicker1").val();
	var vaDateEnd = $("#datetimepicker2").val();
	var vaInputEmployee = $("#InputEmployee").val();
	var vnUserId = $("#userId").val();
	var vnSiteId = $("#siteId").val();

	if(vaDateStart.trim().length == 0 || vaDateEnd.trim().length == 0 || vaInputEmployee.trim().length == 0 
			|| vnUserId.trim().length == 0 || vnSiteId.trim().length == 0)
	{
		$("#modal_content").html("กรุณากรอกข้อมูลให้ครบถ้วน");
		$("#warningModal").modal();
		return;
	}else{
		var url = reporturl+"CS56001R.jsp?siteId="+vnSiteId+"&userId="+vnUserId+"&fromDate="+vaDateStart+"&toDate="+vaDateEnd+"&receiveEmployee="+vaInputEmployee;
		window.open(url);
	}
}